package cn.gson.fengboot.model.pojos;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

@Entity
public class Zbarter {
    private Integer barterId;//换货id
    private TfyclientForm clientId;//客户
    private String barterTheme;//换货主题
    private Zorder orderId;//换货对应的订单
    private Zorder barterOrderNo;//重新发货的订单
    private Zchuku chukuId;//出库单
    private String barterNo;//换货编号
    private String barterWarehouse;//换货退入仓库2
    private Timestamp barterTime;//换货时间
    private Timestamp barterThtime;//退货时间
    private String barterState;//换货状态2
    private String barterAudit;//审核是否通过2
    private List<Zbarterdetails> zbarterdetailsByBarterId;
    private String barterRemark;//换货备注
    private String barterOperator;//负责人


    @Id
    @Column(name = "barter_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Integer getBarterId() {
        return barterId;
    }

    public void setBarterId(Integer barterId) {
        this.barterId = barterId;
    }

    @ManyToOne
    @JoinColumn(name = "client_id", referencedColumnName = "client_id")
    public TfyclientForm getClientId() {
        return clientId;
    }

    public void setClientId(TfyclientForm clientId) {
        this.clientId = clientId;
    }

    @ManyToOne
    @JoinColumn(name = "chuku_id", referencedColumnName = "chuku_id")
    public Zchuku getChukuId() {
        return chukuId;
    }

    public void setChukuId(Zchuku chukuId) {
        this.chukuId = chukuId;
    }

    @ManyToOne
    @JoinColumn(name = "order_id", referencedColumnName = "order_id")
    public Zorder getOrderId() {
        return orderId;
    }

    public void setOrderId(Zorder orderId) {
        this.orderId = orderId;
    }

    @Basic
    @Column(name = "barter_no")
    public String getBarterNo() {
        return barterNo;
    }

    public void setBarterNo(String barterNo) {
        this.barterNo = barterNo;
    }

    @Basic
    @Column(name = "barter_remark")
    public String getBarterRemark() {
        return barterRemark;
    }

    public void setBarterRemark(String barterRemark) {
        this.barterRemark = barterRemark;
    }

    @Basic
    @Column(name = "barter_thtime")
    public Timestamp getBarterThtime() {
        return barterThtime;
    }

    public void setBarterThtime(Timestamp barterThtime) {
        this.barterThtime = barterThtime;
    }

    @Basic
    @Column(name = "barter_theme")
    public String getBarterTheme() {
        return barterTheme;
    }

    public void setBarterTheme(String barterTheme) {
        this.barterTheme = barterTheme;
    }

    @ManyToOne
    @JoinColumn(name = "barter_order_no", referencedColumnName = "order_id")
    public Zorder getBarterOrderNo() {
        return barterOrderNo;
    }

    public void setBarterOrderNo(Zorder barterOrderNo) {
        this.barterOrderNo = barterOrderNo;
    }

    @Basic
    @Column(name = "barter_operator")
    public String getBarterOperator() {
        return barterOperator;
    }

    public void setBarterOperator(String barterOperator) {
        this.barterOperator = barterOperator;
    }

    @Basic
    @Column(name = "barter_time")
    public Timestamp getBarterTime() {
        return barterTime;
    }

    public void setBarterTime(Timestamp barterTime) {
        this.barterTime = barterTime;
    }

    @Basic
    @Column(name = "barter_warehouse")
    public String getBarterWarehouse() {
        return barterWarehouse;
    }

    public void setBarterWarehouse(String barterWarehouse) {
        this.barterWarehouse = barterWarehouse;
    }

    @Basic
    @Column(name = "barter_state")
    public String getBarterState() {
        return barterState;
    }

    public void setBarterState(String barterState) {
        this.barterState = barterState;
    }

    @Basic
    @Column(name = "barter_audit")
    public String getBarterAudit() {
        return barterAudit;
    }

    public void setBarterAudit(String barterAudit) {
        this.barterAudit = barterAudit;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Zbarter zbarter = (Zbarter) o;
        return barterId == zbarter.barterId &&
                Objects.equals(clientId, zbarter.clientId) &&
                Objects.equals(orderId, zbarter.orderId) &&
                Objects.equals(barterNo, zbarter.barterNo) &&
                Objects.equals(barterOrderNo, zbarter.barterOrderNo) &&
                Objects.equals(barterOperator, zbarter.barterOperator) &&
                Objects.equals(barterTime, zbarter.barterTime) &&
                Objects.equals(barterWarehouse, zbarter.barterWarehouse) &&
                Objects.equals(barterState, zbarter.barterState) &&
                Objects.equals(barterAudit, zbarter.barterAudit);
    }

    @Override
    public int hashCode() {
        return Objects.hash(barterId, clientId, orderId, barterNo, barterOrderNo, barterOperator, barterTime, barterWarehouse, barterState, barterAudit);
    }


    @OneToMany(mappedBy = "barterId")
        public List<Zbarterdetails> getZbarterdetailsByBarterId() {
            return zbarterdetailsByBarterId;
        }

        public void setZbarterdetailsByBarterId(List<Zbarterdetails> zbarterdetailsByBarterId) {
            this.zbarterdetailsByBarterId = zbarterdetailsByBarterId;
    }

    @Override
    public String toString() {
        return "Zbarter{" +
                "barterId=" + barterId +
                ", clientId=" + clientId +
                ", orderId=" + orderId +
                ", barterOrderNo=" + barterOrderNo +
                ", barterNo='" + barterNo + '\'' +
                ", barterOperator='" + barterOperator + '\'' +
                ", barterTime=" + barterTime +
                ", barterThtime=" + barterThtime +
                ", barterWarehouse='" + barterWarehouse + '\'' +
                ", barterState='" + barterState + '\'' +
                ", barterAudit='" + barterAudit + '\'' +
                ", zbarterdetailsByBarterId=" + zbarterdetailsByBarterId +
                ", barterTheme='" + barterTheme + '\'' +
                ", barterRemark='" + barterRemark + '\'' +
                '}';
    }
}
